// 获取url链接内字段
export const getUrlCode = () => {
  // 截取url中的code方法
  const url = location.search;
  const winUrl = url;
  const theRequest: any = new Object();
  if (url.indexOf("?") != -1) {
    const str = url.substr(1);
    const strs = str.split("&");
    for (let i = 0; i < strs.length; i++) {
      theRequest[strs[i].split("=")[0]] = strs[i].split("=")[1];
    }
  }
  return theRequest;
}

export const checkPlatform = () => {
  let isWeiXin = false;
  let isPc = false;
  let ua = window.navigator.userAgent.toLowerCase();
  if (ua.match(/MicroMessenger/i)?.toString() == 'micromessenger') {
    isWeiXin = true;
  }
  let system = {
    win: false,
    mac: false
  };
  //检测平台
  let p = navigator.platform;
  system.win = p.indexOf("Win") == 0;
  system.mac = p.indexOf("Mac") == 0;
  if (system.win || system.mac) {
    isPc = true;
  }
  return {
    isWeiXin,
    isPc,
  }
}